package com.fxn.modals;

import ohos.media.image.PixelMap;
import ohos.utils.Parcel;
import ohos.utils.Sequenceable;

/**
 * description : Img
 *
 * @since 2021-04-15
 */
public class Img implements Sequenceable {
    /**
     * Sequenceable
     */
    public static final Sequenceable.Producer
            PRODUCER = new Sequenceable.Producer () {
        /**
         * createFromParcel
         *
         * @param in Parcel in
         * @return Img
         */
        public Img createFromParcel(Parcel in) {
            // Initialize an instance first, then do customized unmarshlling.
            Img instance = new Img();
            instance.unmarshalling(in);
            return instance;
        }
    };

    private String headerDate;
    private String contentUrl;
    private String url;
    private Boolean isSelected;
    private String scrollerDate;
    private String mediaType;
    private int position;
    private PixelMap pixelMap;

    /**
     * 初始化img
     */
    public Img() {
        this("", "", "", "", "");
    }

    /**
     * 初始化img
     *
     * @param headerDate 日期
     * @param contentUrl uri
     * @param url 绝对路径
     * @param scrollerDate scrollerDate
     * @param mediaType mediaType
     */
    public Img(String headerDate, String contentUrl,
                String url, String scrollerDate, String mediaType) {
        this.headerDate = headerDate;
        this.contentUrl = contentUrl;
        this.url = url;
        this.isSelected = false;
        this.scrollerDate = scrollerDate;
        this.mediaType = mediaType;
    }

    /**
     * get HeaderDate
     *
     * @return HeaderDate
     */
    public String getHeaderDate() {
        return headerDate;
    }

    /**
     * set HeaderDate
     *
     * @param headerDate HeaderDate
     */
    public void setHeaderDate(String headerDate) {
        this.headerDate = headerDate;
    }

    /**
     * 获取uri
     *
     * @return uri
     */
    public String getContentUrl() {
        return contentUrl;
    }

    /**
     * 设置uri
     *
     * @param contentUrl uri
     */
    public void setContentUrl(String contentUrl) {
        this.contentUrl = contentUrl;
    }

    /**
     * 获取绝对路径
     *
     * @return url
     */
    public String getUrl() {
        return url;
    }

    /**
     * 设置绝对路径
     *
     * @param url url
     */
    public void setUrl(String url) {
        this.url = url;
    }

    /**
     * 获取是否选中
     *
     * @return 是否选中
     */
    public Boolean getSelected() {
        return isSelected;
    }

    /**
     * 设置是否选中
     *
     * @param selected 是否选中
     */
    public void setSelected(Boolean selected) {
        isSelected = selected;
    }

    /**
     * get ScrollerDate
     *
     * @return ScrollerDate
     */
    public String getScrollerDate() {
        return scrollerDate;
    }

    /**
     * set ScrollerDate
     *
     * @param scrollerDate setScrollerDate
     */
    public void setScrollerDate(String scrollerDate) {
        this.scrollerDate = scrollerDate;
    }

    /**
     * get MediaType
     *
     * @return MediaType
     */
    public String getMediaType() {
        return mediaType;
    }

    /**
     * set MediaType
     *
     * @param mediaType MediaType
     */
    public void setMediaType(String mediaType) {
        this.mediaType = mediaType;
    }

    /**
     * get Position
     *
     * @return position
     */
    public int getPosition() {
        return position;
    }

    /**
     * set Position
     *
     * @param position position
     */
    public void setPosition(int position) {
        this.position = position;
    }

    /**
     * get PixelMap
     *
     * @return pixelMap
     */
    public PixelMap getPixelMap() {
        return pixelMap;
    }

    /**
     * set PixelMap
     *
     * @param pixelMap pixelMap
     */
    public void setPixelMap(PixelMap pixelMap) {
        this.pixelMap = pixelMap;
    }

    @Override
    public String toString() {
        return "Img{" +
                "headerDate='" + headerDate + '\'' +
                ", contentUrl='" + contentUrl + '\'' +
                ", url='" + url + '\'' +
                ", isSelected=" + isSelected +
                ", scrollerDate='" + scrollerDate + '\'' +
                ", mediaType=" + mediaType +
                ", position=" + position +
                '}';
    }

    @Override
    public boolean marshalling(Parcel out) {
        return out.writeString(headerDate) && out.writeString(contentUrl)
                && out.writeString(url) && out.writeString(mediaType)
                && out.writeString(scrollerDate)
                && out.writeInt(position) && out.writeBoolean(isSelected);
    }

    @Override
    public boolean unmarshalling(Parcel in) {
        headerDate = in.readString();
        contentUrl = in.readString();
        url = in.readString();
        mediaType = in.readString();
        scrollerDate = in.readString();
        position = in.readInt();
        isSelected = in.readBoolean();
        return false;
    }
}
